#pragma once

#include <crow.h>
#include <string>
#include <vector>
#include "../models/route.hpp"
#include "../models/status.hpp"
#include "../models/mod.hpp"
#include "../models/cmd.hpp"
#include "../utils/template_manager.hpp"
#include "../utils/session_manager.hpp"

class MainController {
public:
    static void registerRoutes(crow::SimpleApp& app);
    static bool checkSession(const crow::request& req);
    
    // 登录相关
    static crow::response showLogin();
    static crow::response handleLogin(const crow::request& req);
    static crow::response logout();
    
    // 首页相关
    static crow::response showIndex();
    
    // 路由配置相关
    static crow::response showRouteData(const crow::request& req);
    static crow::response handleDelete(int id);
    static crow::response showAddRoute();
    static crow::response handleAddRoute(const crow::request& req);
    static crow::response showUpdateRoute(const crow::request& req);
    static crow::response handleUpdate(const crow::request& req);
    
    // 路由变更相关
    static crow::response showRouteChange();
    static crow::response showVersion();
    
    // 模块和命令相关
    static crow::response showCmdid();
    static crow::response showModid();
    static crow::response showAddMod();
    static crow::response showAddCmd();
    static crow::response handleAddMod(const crow::request& req);
    static crow::response handleAddCmd(const crow::request& req);
    static crow::response deleteMod(const crow::request& req);
    static crow::response deleteCmd(int id);
    static crow::response showEditMod(const crow::request& req);
    static crow::response showEditCmd(const crow::request& req);
    static crow::response editMod(const crow::request& req);
    static crow::response editCmd(const crow::request& req);

    // 新增API方法
    void getModList();
    void getCmdList();
    void deleteMod();
    std::string getResponse() const { return response_; }

private:
    std::string response_;
}; 